/**********************************************************************
 Name:  TestDailyPlanControl
 Purpose:DailyPlanControl 测试用例                                                          
-------                                                             
======================================================
History                                                            
-------                                                            
VERSION    AUTHOR                  DATE                 DETAIL                                
   1.0 -        huangxiaojiang       03/29/2011         Create  
***********************************************************************/
@isTest
private class TestDailyPlanControll{
     static testMethod void test(){
        Profile p=[select  id from profile where  name='Sales Rep - Trade' limit 1];
        User u=new user(alias='hxj',email='xjhuang8140ww7@isoftstone.com',lastName='testing'
               ,languageLocaleKey='zh_CN',localeSidkey='zh_CN' ,TimeZoneSidKey='Asia/Shanghai',EmailEncodingKey='UTF-8',
               profileId=p.id,userName='xjhuang123@isoftstone.com');  
                
         System.runAs(u){
         
             //创建数据用于测试
               hospital__c hp1=new hospital__c(name='testhospital2',nickname__c='nickhp1',approvaltype__c='新增医院1',approvalstatus__c='等待审批'
                   ,Lat__c='23.294649502949286',Lon__c='113.24569702148437');
               insert hp1;
                hospital__c hp2=new hospital__c(name='testhospital2',nickname__c='nickhp2',approvaltype__c='新增医院2',approvalstatus__c='等待审批'
                   ,Lat__c='23.22778052992928',Lon__c='113.29582214355469');
                insert hp2;

                hospital__c hp3=new hospital__c(name='testhospital3',nickname__c='nickhp3',approvaltype__c='新增医院3',approvalstatus__c='等待审批'
                   ,Lat__c='33.22778052992928',Lon__c='103.29512214355469');
                insert hp3;
                                
                HCP__c hcp1=new hcp__c();
                hcp1.name='testhcp';
                hcp1.Hospital__c=hp1.id;
                hcp1.class2__c='决策人1(DM)';
                hcp1.active__c=true;
                hcp1.approvalstatus__c='';
                hcp1.approvaltype__c = '';
                insert hcp1;
                
                HCP__c hcp2=new hcp__c();
                hcp2.name='testhcp';
                hcp2.Hospital__c=hp2.id;
                hcp2.class2__c='决策人2(DM)';
                hcp2.active__c=true;
                hcp2.approvalstatus__c='';
                hcp2.approvaltype__c = '';
                insert hcp2;

                HCP__c hcp3=new hcp__c();
                hcp3.name='testhcp';
                hcp3.Hospital__c=hp3.id;
                hcp3.class2__c='决策人3(DM)';
                hcp3.active__c=true;
                hcp3.approvalstatus__c='';
                hcp3.approvaltype__c = '';
                insert hcp3;
                
                                
                MonthlyCallPlan__c mcp=new MonthlyCallPlan__c(PlanYear__c='2011',PlanMonth__c=string.valueOf(date.today().month())+'月');
                insert mcp;
                
                recordtype cprt=[select id from recordtype where sobjecttype=:'callplan__c' and name=:'日常拜访计划']; 
                CallPlan__c cp1=new CallPlan__c( CallMessage__c = '1Pastor-高水平DHA令宝宝拥有真“智”卓“健”（2010年3月至8月）',
                            CallPurpose__c = '1商谈专业评估',  recordtypeid=cprt.id,name='1callplanname',
                            CallWorkingtype__c='1拜访',CallDate__c=datetime.now(),HCP__c=hcp1.id,PlanType__c='计划外',
                            Monthly_Call_Plan__c=mcp.id,CallPlanDate__c = date.today(),Lat__c='23.085101554603043',Lon__c='113.206083984375');                
                insert cp1;
                CallPlan__c cp2=new CallPlan__c( CallMessage__c = '2Pastor-高水平DHA令宝宝拥有真“智”卓“健”（2010年3月至8月）',
                            CallPurpose__c = '2商谈专业评估',  recordtypeid=cprt.id,name='2callplanname',
                            CallWorkingtype__c='2拜访',CallDate__c=datetime.now(),HCP__c=hcp2.id,PlanType__c='计划内',
                            Monthly_Call_Plan__c=mcp.id,CallPlanDate__c = date.today(),Lat__c='23.22778052992928',Lon__c='113.29582214355469');                
                insert cp2;

                CallPlan__c cp3=new CallPlan__c( CallMessage__c = '3Pastor-高水平DHA令宝宝拥有真“智”卓“健”（2010年3月至8月）',
                            CallPurpose__c = '3商谈专业评估',  recordtypeid=cprt.id,name='3callplanname',
                            CallWorkingtype__c='3拜访',CallDate__c=datetime.now(),HCP__c=hcp3.id,PlanType__c='计划内',CallExecutionstatus__c='是',
                            Monthly_Call_Plan__c=mcp.id,CallPlanDate__c = date.today(),Lat__c='21.22778052992928',Lon__c='113.29582214355469');                
                insert cp3;                
               //测试数据完成
                                                       
              ApexPages.StandardController pageControl1=new ApexPages.StandardController(cp1);
              DailyPlanControl dCPPage1=new DailyPlanControl(pageControl1); 
              dCPPage1.MCPId=mcp.id;
              dCPPage1.onloadAction();
              dCPPage1.findPlanList();
              
              ApexPages.StandardController pageControl2=new ApexPages.StandardController(cp2);
              DailyPlanControl dCPPage2=new DailyPlanControl(pageControl2);
               dCPPage2.MCPId=mcp.id; 
              dCPPage2.onloadAction();
              dCPPage2.findPlanList();
              
              ApexPages.StandardController pageControl3=new ApexPages.StandardController(cp3);
              DailyPlanControl dCPPage3=new DailyPlanControl(pageControl3);
              dCPPage3.onloadAction();
              dCPPage3.findPlanList();
                            
         }                
     }
}